package Demo1;

public class Solution2 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 计算两个数之和
     * @param ss string字符串 表示第一个整数
     * @param tt string字符串 表示第二个整数
     * @return string字符串
     */
    StringBuffer ret = new StringBuffer();
    public String solve (String ss, String tt) {
        // write code here
        int len1 = ss.length() - 1, len2 = tt.length() - 1;

        int tmp = 0;
        while(len1 >= 0 && len2 >= 0) {
            int sum = ss.charAt(len1) - '0' + tt.charAt(len2) - '0' + tmp;
            tmp = sum / 10;
            addHead(sum % 10);
            len1--;
            len2--;
        }
        while(len1 >= 0) {
            int sum = ss.charAt(len1) - '0' + tmp;
            tmp = sum / 10;
            addHead(sum % 10);
            len1--;
        }
        while(len2 >= 0) {
            int sum = tt.charAt(len2) - '0' + tmp;
            tmp = sum / 10;
            addHead(sum % 10);
            len2--;
        }
        if(tmp > 0) addHead(tmp);
        return ret.toString();
    }
    public void addHead(Integer val) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(val);
        stringBuffer.append(ret);
        ret = stringBuffer;
    }
}
class Demo {
    public static void main(String[] args) {
        Solution2 solution2 = new Solution2();
        String solve = solution2.solve("11","99");
        System.out.println(solve);
    }
}